package cn.jflow.boot;

import bp.da.DataSet;
import bp.difference.SystemConfig;
import org.apache.catalina.core.StandardContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.stereotype.Component;
import org.springframework.core.env.Environment;


@Component
public class MyApplicationRunner implements ApplicationRunner {
    @Autowired
    Environment env;
    private final TomcatServletWebServerFactory tomcatServletWebServerFactory;

    public MyApplicationRunner(TomcatServletWebServerFactory tomcatServletWebServerFactory) {
        this.tomcatServletWebServerFactory = tomcatServletWebServerFactory;
    }
    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("Application has started! (ApplicationRunner)");
//        //判断打包的方式
//        boolean isJarRun = SystemConfig.isJarRun();
//        String path = "";
//        String port = env.getProperty("server.port");
//        String contextPath = env.getProperty("server.servlet.context-path");
//
//        if(isJarRun)
//            path = SystemConfig.getPathOfXML() + "Enum/Map.xml";
//        else{
//            path = System.getProperty("user.dir");
//            if(path.contains("jflow-web")==false)
//                path+="/jflow-web";
//            path+="/src/main/webapp/DataUser/WF/Data/XML/Enum/Map.xml";
//        }
//        DataSet ds = new DataSet();
//        try{
//            ds.readXml(path);
//        }catch(Exception e){
//            if(isJarRun == false)
//                SystemConfig.getAppSettings().put("IsStartJarPackage",1);
//            else
//                SystemConfig.getAppSettings().put("IsStartJarPackage",0);
//            ds.readXml(path);
//        }
    }
}
